DATA_PKG_FOLDER_NAME=$1
if [ -z "$DATA_PKG_FOLDER_NAME" ]; then
  DATA_PKG_FOLDER_NAME="coin2_data_pkg"
fi

COIN_ROOT="$(git rev-parse --show-toplevel)"
DATA_PKG_ROOT=$COIN_ROOT/../$DATA_PKG_FOLDER_NAME
echo "coin2_data_pkg path:$DATA_PKG_ROOT"

function deploy_coin2_data {
  mkdir -p $DATA_PKG_ROOT/$1
  rsync -avh $3 --delete -L $COIN_ROOT/$1/$2 $DATA_PKG_ROOT/$1/
}

set -x
deploy_coin2_data . data "--exclude test"

mkdir -p $DATA_PKG_ROOT/cc/coin2
rsync -avh --exclude "*.cc" --exclude "*.cpp" --exclude "*.h" --exclude "*.md" --exclude README.txt -m --delete -L $COIN_ROOT/cc/coin2/exchange $DATA_PKG_ROOT/cc/coin2/


echo "Build and Copy to $DATA_PKG_ROOT Successfully!!"
echo "You must push your change later!!"
